package com.core;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.dao.DAOFactory;
import com.dao.EmployeeDAO;
import com.dao.SeatDAO;
import com.objects.Employee;

public class EmployeeManager {
	
	public List<Employee> searchEmployee(String inputEmployeeSearchPara){
		List<Employee> employees = new ArrayList<Employee>();
		
		Employee employee = new Employee();
		//get a reference to EmployeeDAO object
		EmployeeDAO empDAO = DAOFactory.getEmployeeDAO();
		//call insert method by passing user object
		try {
			if (inputEmployeeSearchPara == "*"){
				employees = empDAO.searchAllEmployee();
			} else if (Helper.isInteger(inputEmployeeSearchPara)){
				employee = empDAO.searchEmployee(inputEmployeeSearchPara);
				if (employee.getEmployeeID() != null){
					employees.add(employee);
				}
			} else {
				employee = empDAO.searchEmployee(inputEmployeeSearchPara);
			}		
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return employees;
	}
	public Employee exportEmployeeInfo(String employeeId){
		Employee employee = new Employee();
		return employee;
	}
	
	public boolean updateEmployeeSeat(String employeeId, String newSeatCode){
		return false;
	}
	
	public  boolean deleteEmployeeSeat(Employee employee){
		boolean stat = false;
		//get a reference to SeatDAO object
		SeatDAO seatDAO = DAOFactory.getSeatDAO();
		//call insert method by passing user object
		try {
			stat = seatDAO.deleteEmployeeSeat(employee);

			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return stat;
	}

}
